package com.woniuxy.carlife.carlifeuserweb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.carlife.carlifecommonsweb.exception.CarlifeGlobalException;
import com.woniuxy.carlife.carlifeuserweb.entity.Carbrand;
import com.woniuxy.carlife.carlifeuserweb.entity.Carmodel;
import com.woniuxy.carlife.carlifeuserweb.mapper.CarbrandMapper;
import com.woniuxy.carlife.carlifeuserweb.mapper.CarmodelMapper;
import com.woniuxy.carlife.carlifeuserweb.service.CarmodelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zjq
 * @ClassName:CarmodelServiceImpl
 * @Description:
 * @date 2021/4/6 20:02
 **/

@Service
public class CarmodelServiceImpl extends ServiceImpl<CarmodelMapper, Carmodel> implements CarmodelService {

    @Resource
    CarmodelMapper carmodelMapper;

    /*
     * 功能描述〈查询汽车型号〉
     * @author:zjq
     * @param:
     * @return:
     * @Date 2021/4/10 17:35
     * @throws
     */

    @Override
    public List<Carmodel> findCarmodel()  {
        QueryWrapper<Carmodel> carmodelQueryWrapper = new QueryWrapper<>();
        List<Carmodel> carmodels = carmodelMapper.selectList(carmodelQueryWrapper);

        return carmodels == null ? null : carmodels;
    }

    /*
     * 功能描述〈根据汽车型号id查询〉
     * @author:zjq
     * @param:
     * @return:
     * @Date 2021/4/10 17:37
     * @throws
     */

    @Override
    public Carmodel findCarmodelByCarmodelId(Carmodel carmodelId)  {
        QueryWrapper<Carmodel> carmodelQueryWrapper = new QueryWrapper<>();
        carmodelQueryWrapper.eq("carmodel_id", carmodelId);
        Carmodel carmodel = carmodelMapper.selectOne(carmodelQueryWrapper);

        return carmodel == null ? null : carmodel;
    }
}
